package com.example.onlineeducation.mapper

import com.example.onlineeducation.data.constant.OfflineStudyLiveState
import com.example.onlineeducation.data.entity.OfflineStudyLiveListEntity
import com.example.onlineeducation.data.json.OfflineStudyLiveListJson
import com.example.onlineeducation.utils.YcTimeUtils
import com.yc.jetpacklib.extension.ycToNoEmpty

import com.yc.jetpacklib.mapper.IMapper
import com.yc.jetpacklib.utils.YcTime

class OfflineStudyLiveListMapper : IMapper<List<OfflineStudyLiveListJson>?, List<OfflineStudyLiveListEntity>?> {
    override fun map(input: List<OfflineStudyLiveListJson>?): List<OfflineStudyLiveListEntity>? {
        return input?.map {
            OfflineStudyLiveListEntity(
                it.id!!,
                it.mediaInfo?.webPath,
                it.name.ycToNoEmpty(),
                YcTimeUtils.stringToString(it.beginTime, "-", YcTime.FORMAT_TIME_SECOND, "yyyy.MM.dd HH:mm"),
                YcTimeUtils.stringToString(it.endTime, "-", YcTime.FORMAT_TIME_SECOND, "yyyy.MM.dd HH:mm"),
                OfflineStudyLiveState.getStudyLiveState(it.beginTime, it.endTime),
                it.projects?.name.ycToNoEmpty(),
                it.state.ycToNoEmpty()
            )
        }
    }
}

